// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class FrequencyEncodingPreprocessor
{
	[JsonInclude, JsonPropertyName("feature_name")]
	public string FeatureName { get; set; }
	[JsonInclude, JsonPropertyName("field")]
	public string Field { get; set; }
	[JsonInclude, JsonPropertyName("frequency_map")]
	public IDictionary<string, double> FrequencyMap { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Preprocessor(FrequencyEncodingPreprocessor frequencyEncodingPreprocessor) => Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Preprocessor.FrequencyEncoding(frequencyEncodingPreprocessor);
}

public sealed partial class FrequencyEncodingPreprocessorDescriptor : SerializableDescriptor<FrequencyEncodingPreprocessorDescriptor>
{
	internal FrequencyEncodingPreprocessorDescriptor(Action<FrequencyEncodingPreprocessorDescriptor> configure) => configure.Invoke(this);

	public FrequencyEncodingPreprocessorDescriptor() : base()
	{
	}

	private string FeatureNameValue { get; set; }
	private string FieldValue { get; set; }
	private IDictionary<string, double> FrequencyMapValue { get; set; }

	public FrequencyEncodingPreprocessorDescriptor FeatureName(string featureName)
	{
		FeatureNameValue = featureName;
		return Self;
	}

	public FrequencyEncodingPreprocessorDescriptor Field(string field)
	{
		FieldValue = field;
		return Self;
	}

	public FrequencyEncodingPreprocessorDescriptor FrequencyMap(Func<FluentDictionary<string, double>, FluentDictionary<string, double>> selector)
	{
		FrequencyMapValue = selector?.Invoke(new FluentDictionary<string, double>());
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("feature_name");
		writer.WriteStringValue(FeatureNameValue);
		writer.WritePropertyName("field");
		writer.WriteStringValue(FieldValue);
		writer.WritePropertyName("frequency_map");
		JsonSerializer.Serialize(writer, FrequencyMapValue, options);
		writer.WriteEndObject();
	}
}